package algorithm;

import java.util.Arrays;
import java.util.HashMap;

public class leetcode_1365 {
    public int[] smallerNumbersThanCurrent(int[] nums) {
        HashMap<Integer, Integer> map=new HashMap<>();
        int len=nums.length;
        int[] result=new int[len];
        for(int i=0;i<len;++i){
            result[i]=nums[i];
        }
        Arrays.sort(result);
        for(int i=0;i<len;++i){
            if(!map.containsKey(result[i])){
                map.put(result[i],i );
            }
        }
        for(int i=0;i<len;++i){
            result[i]= map.get(nums[i]);
        }
        return result;
    }
}
